<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>猫小朵</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- jquery -->
    <script src="https://cdn.bootcss.com/jquery/2.2.3/jquery.min.js"></script>
</head>
<body>

<div class="form-control" id="top-toolbar">
    <div class="form-group">
        <label class="control-label" for="username">用户名</label>
        <div>
            <input class="form-control well" id="username" type="text"/>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label" for="password">密码</label>
        <div>
            <input class="form-control well" id="password" type="password"/>
        </div>
    </div>
    <button id="login">登录</button>
</div>

</body>
</html>

<script>
    $("#login").click(function () {
        $.post({
            url: "/user/login",
            data: {
                username: $("#username").val(),
                password: $("#password").val()
            },
            success(result) {
                if (result.success) {
                    sessionStorage.setItem("username",result.data);
                    location.href = result.msg + '.html';
                } else {
                   alert(result.data);
                }
            },
        });
    })


</script>
